home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2001 December / pcwk12201b.iso / Wersje pelne i specjalne / Winamp 2.77 i 3.0beta / wasabi-sdk_beta1.exe / studio / common / dropwnd.cpp < prev    next >
C/C++ Source or Header  |  2001-10-08  |  5KB  |  151 lines

  1. /*
  2.  
  3.   Nullsoft WASABI Source File License
  4.  
  5.   Copyright 1999-2001 Nullsoft, Inc.
  6.  
  7.     This software is provided 'as-is', without any express or implied
  8.     warranty.  In no event will the authors be held liable for any damages
  9.     arising from the use of this software.
  10.  
  11.     Permission is granted to anyone to use this software for any purpose,
  12.     including commercial applications, and to alter it and redistribute it
  13.     freely, subject to the following restrictions:
  14.  
  15.     1. The origin of this software must not be misrepresented; you must not
  16.        claim that you wrote the original software. If you use this software
  17.        in a product, an acknowledgment in the product documentation would be
  18.        appreciated but is not required.
  19.     2. Altered source versions must be plainly marked as such, and must not be
  20.        misrepresented as being the original software.
  21.     3. This notice may not be removed or altered from any source distribution.
  22.  
  23.  
  24.   Brennan Underwood
  25.   brennan@nullsoft.com
  26.  
  27. */
  28.  
  29.  
  30. #if 0
  31. #include "dropwnd.h"
  32.  
  33. #include "filename.h"
  34.  
  35. #include "../studio/api.h"
  36.  
  37. #include <shlobj.h>
  38. #include <shellapi.h>
  39.  
  40. #if 0
  41. class DropTarget: public IDropTarget {
  42. public:
  43.     STDMETHODIMP QueryInterface (REFIID riid, LPVOID * ppvObj)
  44.     { return 0; }
  45.     STDMETHODIMP_(ULONG) AddRef ()
  46.     { return 0; }
  47.     STDMETHODIMP_(ULONG) Release ()
  48.     { return 0; }
  49.  
  50.     STDMETHODIMP DragEnter(IDataObject * pDataObject, DWORD grfKeyState, POINTL pt, DWORD * pdwEffect) 
  51.     { 
  52.       return S_OK; 
  53.     }
  54.     STDMETHODIMP DragOver(DWORD grfKeyState, POINTL pt, DWORD * pdwEffect)
  55.     { return 0; }
  56.     STDMETHODIMP DragLeave()
  57.     { return 0; }
  58.     STDMETHODIMP Drop(IDataObject * pDataObj, DWORD grfKeyState, POINTL pt, DWORD * pdwEffect)
  59.     { 
  60.       POINT p={pt.x, pt.y};
  61.       HWND wnd=WindowFromPoint(p);
  62.       //int is_main=wnd==hMainWindow;
  63.  
  64.       HRESULT hr = S_OK;
  65.       if (pDataObj) 
  66.       {
  67.         char *url;
  68.         // Important: these strings need to be non-Unicode (don't compile UNICODE)
  69.         unsigned short cp_format_url = RegisterClipboardFormat(CFSTR_SHELLURL);
  70.         //Set up format structure for the descriptor and contents
  71.         FORMATETC format_url = 
  72.             {cp_format_url, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL};
  73.         FORMATETC format_file = 
  74.             {CF_HDROP, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL};
  75.         // Check for URL
  76.         hr = pDataObj->QueryGetData(&format_url);
  77.         if (hr == S_OK) 
  78.         { 
  79.           // Get the descriptor information
  80.           STGMEDIUM storage= {0,0,0};
  81.           hr = pDataObj->GetData(&format_url, &storage);
  82.           url=(char *)GlobalLock(storage.hGlobal);
  83.           if(url)
  84.           {
  85.             DropWnd *dw=(DropWnd*)GetWindowLong(wnd,GWL_USERDATA);
  86.             dw->addUrl(url);
  87.           }
  88.           GlobalUnlock(url);
  89.           GlobalFree(url);
  90.         } else {
  91.           // check for file
  92.           hr=pDataObj->QueryGetData(&format_file);
  93.           if(hr==S_OK)
  94.           {
  95.             STGMEDIUM medium;
  96.             HRESULT hr = pDataObj->GetData (&format_file, &medium);
  97. //            if(!is_main)
  98.             {
  99.               RECT r;
  100.               GetWindowRect(wnd,&r);
  101.               LPDROPFILES d = (LPDROPFILES)GlobalLock(medium.hGlobal);
  102.               d->pt.x=pt.x-r.left;
  103.               d->pt.y=pt.y-r.top;
  104.               d->fNC=FALSE;
  105.               GlobalUnlock(d);
  106.             }
  107.             SendMessage(wnd,WM_DROPFILES,(WPARAM)medium.hGlobal,0);
  108.             GlobalFree(medium.hGlobal);
  109.           }
  110.         }
  111.       }
  112.       return S_OK; 
  113.     }
  114. };
  115. static DropTarget m_target;
  116. #endif
  117.  
  118. #if 0//BU -- doesn't work
  119. void DropWnd::addUrl(const char *url) {
  120.   onExternalDropBegin();
  121.   
  122.   api->main_enableInput(FALSE);
  123.   SetCursor(LoadCursor(NULL, IDC_WAIT));
  124.   
  125.   addDragItem(DD_FILENAME, new FilenameI(url));
  126.  
  127.   SetCursor(LoadCursor(NULL, IDC_ARROW));
  128.   api->main_enableInput(TRUE);
  129.  
  130.   POINT dp;
  131.   GetCursorPos(&dp); // FUCKO would be better to somehow get this from the drop, but oh well.
  132.   dragging = 1;
  133.   if (dragEnter(this)) {
  134.     if (dragOver(dp.x, dp.y, this)) dragDrop(this, dp.x, dp.y);
  135.   } else {
  136.     dragLeave(this);
  137.   }
  138.   dragging = 0;
  139.   // remove data
  140.   int nitems, pos = dragCheckData(DD_FILENAME, &nitems);
  141.   ASSERT(pos >= 0);
  142.   Filename *fn = (Filename *)dragGetData(pos, 0);
  143.   delete fn;
  144.   resetDragSet();
  145.   
  146.   onExternalDropEnd();
  147. }
  148.  
  149. #endif
  150. #endif
  151.